#列表的遍历练习

list1=['a1','a2','a3']

#使用while遍历
print("使用while遍历:")
def list_while_func(mylist):
    list_len = len(mylist)
    i= 0
    while i<list_len:
        print(f"第{i}个值为:{mylist[i]}")
        i+=1

list_while_func(list1)
#使用for遍历
print("使用for遍历:")
def list_for_func(mylist):
    i=0
    for x in mylist:
        print(f"第{i}个值为：{x}")
        i+=1

list_for_func(list1)
